package control.connector;

import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.Arrays;

import connector.rmiServer.CentralClient;
import connector.rmiServer.ServerService;
import control.connector.impl.ClientImpl;


public class ConRMI {

	//private static final String SERVER_IP = "10.0.1.8";
	private static final String SERVER_IP = "localhost";

	private static final int SERVER_PORT = 1099;
	private static ServerService server;

	// We don't need it anymore
	/*private static void connect() throws RemoteException, NotBoundException{
		
//		if (System.getSecurityManager() == null)
//			System.setSecurityManager(new RMISecurityManager());
		Registry registry = LocateRegistry.getRegistry(SERVER_IP, SERVER_PORT);
		System.out.println("Registry is providing the following services,");
		for (String string : Arrays.asList(registry.list())) {
			System.out.println("Service: " + string);
		}
		server = (ServerService) registry.lookup("ServerService");
		CentralClient clientStub = (CentralClient) UnicastRemoteObject
		.exportObject(new ClientImpl(), 0);
		server.registerClient(clientStub);
		server.sendMessage("Alex connected...");
		//StatusMessage sm = new StatusMessage();
//		sm.setMessage("Hallo er der nogen???");
	//	System.out.println(sm.getMessage());
	}
	*/
	
	// We don't need this one either
	/*public static ServerService getServer(){
		if (server==null){
			try {
				connect();
			} catch (RemoteException e) {
				e.printStackTrace();
			} catch (NotBoundException e) {
				e.printStackTrace();
			}
		}
		return server;
	}*/
}